/**
 * 分页工具
 * @param tableId
 * 			传入tableId在之后追加分页
 * @param data
 * 			分页信息data
 * @param divId
 * 			生成分页divId
 */
function pageNation(tableId,data,divId){
	//组装分页控件
	var startCount = (data.currentPage - 1) * data.numPerPage + 1;
	var endCount = data.currentPage * data.numPerPage;
				
	var prevPage = data.currentPage - 1;
	var nextnPage = data.currentPage + 1;
				
	if(data.currentPage == data.pageCount){
		nextnPage = data.pageCount
	}
				
	html = '';
	if(data.recordList == null || data.recordList == undefined || data.recordList.length == 0){
		html +='<div id="'+divId+'" class="row DTTTFooter" style="height:40px; line-height:40px; text-align:center; font-size:14px;">'
					+'<strong>没有数据</strong>';
	}else{
		html +='<div id="'+divId+'" class="row DTTTFooter" style="margin: 0;padding: 5px 5px 2px 10px;">';
		html +='<div class="col-sm-6">'
			+'<div class="dataTables_info" id="simpledatatable_info" role="alert" aria-live="polite" aria-relevant="all">'
			+'当前显示 '+startCount+' 到 ';
					
		if(endCount<data.totalCount){
			html += endCount+' 条 , 共 '+ data.totalCount+' 条</div></div>';
		}else{
			html += data.totalCount+' 条, 共 '+ data.totalCount+' 条</div></div>';
		}
		html +='<div class="col-sm-6">'
	    	+'<div class="dataTables_paginate paging_bootstrap" id="simpledatatable_paginate">'
			+'<ul class="pagination">';
			
		if(data.currentPage>1){
			html +='<li class="prev"><a href="javascript:goPage(1,'+tableId+');">首页</a></li>';
		}
			
		if(data.currentPage==1){
			html +='<li class="prev disabled"><a href="javascript:;">上一页</a></li>';
		}else{
			html +='<li class="prev"><a href="javascript:goPage('+prevPage+','+tableId+');">上一页</a></li>';
		}
			
		var offsetStart=1;
		var offsetEnd=data.pageCount;
		if(offsetEnd > 5){
			if(offsetEnd - data.currentPage >= 2){
				offsetEnd = data.currentPage + 2;
			}
			offsetStart = offsetEnd - 4;
			if(offsetStart < 1){
				offsetStart = 1;
				offsetEnd = 5;
			}
		}
			
		for(var i = offsetStart;i <= offsetEnd ;i++){
			if(i==data.currentPage){
				html +='<li class="active">';
			}else{
					
				html +='<li>';
			}
			html +='<a href="javascript:goPage('+ i +','+tableId+');">'+ i +'</a></li>';
		}
			
		if(data.currentPage == data.pageCount){
				
			html +='<li class="next disabled"><a href="javascript:;">下一页</a></li>';
		}else{
			html +='<li  class="next"><a href="javascript:goPage('+ nextnPage +','+tableId+');">下一页</a></li>';
		}
			
		if(data.currentPage < data.pageCount){
				
			html +='<li class="next"><a href="javascript:goPage('+ data.pageCount +','+tableId+');">尾页</a></li>';
		}
			
		html +='</ul></div></div>';
	}	
	
	html +='</div>';	
	$('#'+tableId).after(html);		
				
}

function goPage(page,tableId)
{
	searchPage(page,tableId);
	
}